import React from 'react';
import { AxFormItemBase } from '../lib/AxFormItemBase';
import { AxFormItemBaseProps } from '../lib/AxFormItemBaseProps.d';
import { AxLabel as AxBaseLabel } from '@/components/AxBase';
import { axhelper } from '@/shared/axhelper';

export const AxLabel: React.FC<AxFormItemBaseProps> = props => {
  const { isLabel = false, ...rest } = props;

  return <AxFormItemBase WrappedComponent={AxBaseLabel} {...rest} />;
};

/**
 * 自定义枚举显示标签
 * @param enumName 枚举类型
 */
export const AxLabelEnum: React.FC<{ enumName: string } & AxFormItemBaseProps> = props => {
  const { enumName, value, ...rest } = props;

  return <AxLabel {...rest} value={axhelper.getDicText(enumName, value)} />;
};

/** 自定义 margin-bottom:0px 的显示标签 */
export const AxLabelNoMarginBottom: React.FC<AxFormItemBaseProps> = props => {
  return <AxLabel formItemClassName="ant-form-item-ax" {...props} />;
};

/**
 * 自定义 margin-bottom:0px 枚举显示标签
 * @param enumName 枚举类型
 */
export const AxLabelEnumNoMarginBottom: React.FC<{
  enumName: string;
} & AxFormItemBaseProps> = props => {
  return <AxLabelEnum formItemClassName="ant-form-item-ax" {...props} />;
};
